//
//  ZWProDetailCell.m
//  NewProject
//
//  Created by tongtong on 2018/5/18.
//  Copyright © 2018年 chenIos. All rights reserved.
//

#import "ZWProDetailCell.h"
@interface ZWProDetailCell()
@property (nonatomic,strong) UIImageView *imag;//图标
@property (nonatomic,strong) UILabel *contentLabel;//标题
@property (nonatomic,strong) UILabel *moneyLabel;//数目
@property (nonatomic,strong) UILabel *switchLabel;//转换数目
@property (nonatomic,strong) UIView *lineView;//分割线
@end
@implementation ZWProDetailCell
- (void)setDate:(NSString *)date address:(NSString *)address transactionNum:(NSNumber *)num
{
    self.contentLabel.text = address;
    self.switchLabel.text = date;
    if (num > 0) {
        self.moneyLabel.textColor = [UIColor colorWithHexString:@"#4296c6"];
        self.moneyLabel.text = [@"+"stringByAppendingString:num.stringValue];
    }else
    {
        self.moneyLabel.textColor = [UIColor colorWithHexString:@"#f54848"];
        self.moneyLabel.text = num.stringValue;
    }
}
#pragma mark - init
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview];
    }
    return self;
}

#pragma mark - add subviews
- (void)addSubview {
    [self addSubview:self.imag];
    [self addSubview:self.contentLabel];
    [self addSubview:self.moneyLabel];
    [self addSubview:self.lineView];
    [self addSubview:self.switchLabel];
    [self layoutSubviews];
}
#pragma mark - layout subviews
- (void)layoutSubviews {
    ZWWeakSelf;
    [_imag mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(@Scare_Width(24));
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.equalTo(@Scare_Width(15));
        make.size.mas_equalTo(CGSizeMake(Scare_Width(38), Scare_Width(38)));
    }];
    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.imag.mas_top).mas_offset(-3);
        make.left.equalTo(weakSelf.imag.mas_right).offset(Scare_Width(18));
//        make.size.mas_equalTo(CGSizeMake(Scare_Width(120), Scare_Width(20)));

    }];
   
    [_switchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(weakSelf.imag.mas_bottom).offset(Scare_Width(3));
        make.left.equalTo(weakSelf.contentLabel.mas_left);
        
    }];
    [_moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@Scare_Width(23));
        make.right.equalTo(self.mas_right).offset(-Scare_Width(15));
    }];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_bottom).offset(-Scare_Width(0.5));
        make.left.equalTo(self.mas_left);
        make.size.mas_equalTo(CGSizeMake(SCREEN_W, Scare_Width(0.5)));
    }];
    
    
}
#pragma mark --set---
- (UIImageView *)imag {
    if (!_imag) {
        _imag = [[UIImageView alloc] init];
        _imag.image = [UIImage imageNamed:@"icon_imag"];
        _imag.layer.cornerRadius = Scare_Width(19);
        _imag.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _imag;
}
- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.font = H_Medium4;
        _contentLabel.textColor = [UIColor colorWithHexString:@"999999"];
        _contentLabel.text = @"dsjlfdskafldsdfkdsf";
    }
    return _contentLabel;
}
- (UILabel *)moneyLabel {
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc] init];
        _moneyLabel.textColor = COLOR_RED;
        _moneyLabel.font = H_Medium3;
        _moneyLabel.text= @"-0.0001";
        _moneyLabel.textAlignment = NSTextAlignmentRight;
    }
    return _moneyLabel;
}
- (UILabel *)switchLabel {
    if (!_switchLabel) {
        _switchLabel = [[UILabel alloc] init];
        _switchLabel.textColor = [UIColor colorWithHexString:@"cccccc"];
        _switchLabel.font = H_Medium6;
        _switchLabel.text = @"12日前";
    }
    return _switchLabel;
}
-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = COLOR_LIGHT_GRAY;
    }
    return _lineView;
}
@end
